﻿function functionDiscard() {
    var idBooking = $("#ModelId").val();
    if (idBooking != 0) {
        var request = $.ajax({ url: del_URL,
            type: "GET",
            data: { idBooking: parseInt(idBooking) },
            dataType: "html",
            async: false
        });
        request.done(function (ans) {
            alert('Successfully deleted');
        });
    }
    else {
        alert('Discarded')
    }
}

function functionGetBooking(bookingButton) {
    var bookingId = $(bookingButton).parent("div").attr("id");
    var request = $.ajax({ url: get_URL,
        type: "GET",
        data: { idBooking: parseInt(bookingId) },
        dataType: "html",
        async: false
    });
    request.done(function (ans) {
        $(ans).appendTo('#booking')
    });
}

function functionSaveBooking() {
    var form = $('#booking').children("form");
    var request = $.ajax({
        type: "POST",
        url: form.attr('action'),
        data: form.serialize()
    });
}
